package com.example.mine

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.GridLayoutManager
import com.alibaba.android.arouter.launcher.ARouter
import com.example.base.view.BaseFragment
import com.example.mine.adapter.MineUIAdapter
import com.example.mine.databinding.FragmentMineBinding
import com.example.mine.entity.MineUIEntity
import dagger.hilt.android.AndroidEntryPoint


@AndroidEntryPoint
class MineFragment : BaseFragment<FragmentMineBinding>() {
    override fun getLayoutId(): Int =R.layout.fragment_mine
    private val mineUIAdapter=MineUIAdapter()
    private val mineList: MutableList<MineUIEntity> = mutableListOf()
    override fun initView() {
        mineList.clear()
        mineList.add(MineUIEntity(R.drawable.ic_mine_1,"访客管理"))
        mineList.add(MineUIEntity(R.drawable.ic_mine_2,"物业服务"))
        mineList.add(MineUIEntity(R.drawable.ic_mine_3,"社区活动"))
        mineList.add(MineUIEntity(R.drawable.ic_mine_4,"设施预约"))
        mineList.add(MineUIEntity(R.drawable.ic_mine_5,"生活服务"))
        mineList.add(MineUIEntity(R.drawable.ic_mine6,"门禁管理"))
        //UI数据
        mDataBinding.rvMine.adapter=mineUIAdapter
        mDataBinding.rvMine.layoutManager= GridLayoutManager(requireContext(),4)
        mineUIAdapter.data.clear()
        mineUIAdapter.data.addAll(mineList)
        mineUIAdapter.notifyDataSetChanged()
        mineUIAdapter.setOnItemClickListener { adapter, view, position ->
            when(mineUIAdapter.getItem(position).name){
                "物业服务" ->{
                    ARouter.getInstance().build("/charge/ChargeListActivity").navigation()
                }
            }
        }
    }

}